package com.simple.gateway.center.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.simple.gateway.center.basedata.common.Result;
import com.simple.gateway.center.domian.application.dto.ApplicationInterfaceDTO;
import com.simple.gateway.center.domian.application.dto.ApplicationInterfaceMethodDTO;
import com.simple.gateway.center.domian.application.dto.ApplicationSystemDTO;
import com.simple.gateway.center.application.IApplicationManageService;
import com.simple.gateway.center.domian.manage.dto.GatewayDistributionDTO;
import com.simple.gateway.center.domian.manage.dto.GatewayServerDTO;
import com.simple.gateway.center.domian.manage.dto.GatewayServerDetailDTO;
import com.simple.gateway.center.application.IConfigManageService;
import com.simple.gateway.center.web.param.ApplicationCompositeParam;
import com.simple.gateway.center.web.param.GatewayServerCompositeParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 项目: simple-gateway
 * <p>
 * 功能描述: 网关综合web层
 *
 * @author: WuChengXing
 * @create: 2023-08-12 17:43
 **/
@RestController
@RequestMapping("/gateway/api/composite")
@CrossOrigin
public class CompositeManageController {

    @Resource
    private IApplicationManageService applicationManageService;

    @Resource
    private IConfigManageService configManageService;

    @GetMapping("/pageGatewayServer")
    public Result<Page<GatewayServerDTO>> pageGatewayServer(@RequestParam("groupName") String groupName,
                                                            @RequestParam("pageNum") Integer pageNum,
                                                            @RequestParam("pageSize") Integer pageSize) {
        return Result.success(configManageService.pageGatewayServer(groupName, pageNum, pageSize));
    }

    @PostMapping("/pageGatewayServerDetail")
    public Result<Page<GatewayServerDetailDTO>> pageGatewayServerDetail(@RequestBody GatewayServerCompositeParam param) {
        return Result.success(configManageService.pageGatewayServerDetail(param));
    }

    @PostMapping("/pageGatewayDistribution")
    public Result<Page<GatewayDistributionDTO>> pageGatewayDistribution(@RequestBody GatewayServerCompositeParam param) {
        return Result.success(configManageService.pageGatewayDistribution(param));
    }

    @PostMapping("/pageApplicationSystem")
    public Result<Page<ApplicationSystemDTO>> pageApplicationSystem(@RequestBody ApplicationCompositeParam param) {
        return Result.success(applicationManageService.pageApplicationSystem(param));
    }

    @PostMapping("/pageApplicationInterface")
    public Result<Page<ApplicationInterfaceDTO>> pageApplicationInterface(@RequestBody ApplicationCompositeParam param) {
        return Result.success(applicationManageService.pageApplicationInterface(param));
    }

    @PostMapping("/pageApplicationMethod")
    public Result<Page<ApplicationInterfaceMethodDTO>> pageApplicationMethod(@RequestBody ApplicationCompositeParam param) {
        return Result.success(applicationManageService.pageApplicationMethod(param));
    }

}
